package queue;

import heap.MaxHeap;

public class PriorityQueue<E extends Comparable<E>> implements Queue<E> {


    private MaxHeap<E> maxHeap;

    public PriorityQueue(){
        maxHeap = new MaxHeap<E>();
    }


    /**
     * 入队
     * @param e
     */
    @Override
    public void enqueue(E e) {
        maxHeap.add(e);
    }


    /**
     * 出对
     * @return
     */
    @Override
    public E dequeue() {
        //提取最大堆中的最大值
        return maxHeap.extrackMax();
    }

    @Override
    public E getFront() {
        return maxHeap.findMax();
    }

    @Override
    public int getSize() {
        return maxHeap.size();
    }

    @Override
    public boolean isEmpty() {
        return maxHeap.isEmpty();
    }
}
